#!/bin/bash
#

nginx_cmd=/usr/loacl/nginx/sbin/nginx

#判断脚本是否有参数
if [ -z $1 ]; then
	echo "help:$0<start|stop|restart|status|reload>"
	exit 69
fi

case $1 in
	start)
		$nginx_cmd
		if [ $? -eq 0 ]; then
			echo "nginx启动成功"
		else
			echo "nginx启动失败"
		fi
	;;
	stop)
		$nginx_cmd -s stop
	;;
	restart)
		$nginx_cmd -s stop
		sleep 1
		$nginx_cmd
	;;
	status)
		if [ -f $nginx_cmd_file ]; then
			echo "nginx(PID $(cat $nginx_pid_file)) is running"
		else
			echo "nginx is stopped"
		fi
	;;
	reload)
		kill -HUP $(cat $nginx_pid_file)
	;;
	*)
		echo "help: $0 <start|stop|restart|status|reload>"
	;;
esac
